/* 
 * AUTHOR: Kevin Lam
 */

package com.apps.ubc.cc;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.apps.datastore.NotifierDatastore;
import com.apps.datastore.dao.ContactInformationObject;
import com.apps.datastore.dao.UniqueCourseObject;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.EntityNotFoundException;
import com.google.appengine.api.taskqueue.Queue;
import com.google.appengine.api.taskqueue.QueueFactory;
import com.google.appengine.api.taskqueue.TaskOptions;

public class UpdateCacheWorkerServlet extends HttpServlet {
	
	private static final Logger log = Logger.getLogger(UpdateCacheWorkerServlet.class.getName());

	public void doPost(HttpServletRequest req, HttpServletResponse resp) {
		NotifierDatastore d = new NotifierDatastore();
		String out = null;
		boolean update = true;
		try {
			d.updateCache();
		} catch (EntityNotFoundException e) {
			out = "Update cache failed: " + e.getMessage();
			update = false;
			e.printStackTrace();
		} finally {
			if(!update)
				log.severe(out);
		}
	}

}
